package com.xpjhs.permission.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;

import com.xpjhs.role.model.Role;

/**
 * 
 * @ClassName:Permission
 * @Description:{todo}
 * @author luckyboyguo@126.com
 * @date:2015年1月16日上午10:51:15
 */
@Entity
@Table(name="xpjhs_permission")
public class Permission implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id ;
	private String permission;
	private String title;
	public String getPermission() {
		return permission;
	}
	public void setPermission(String permission) {
		this.permission = permission;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@ManyToOne
	@JoinColumn(name = "parent_id")
	public Permission getParent() {
		return parent;
	}
	public void setParent(Permission parent) {
		this.parent = parent;
	}
	@OneToMany(mappedBy = "parent", cascade = { CascadeType.REMOVE })
	public List<Permission> getChildren() {
		return children;
	}
	public void setChildren(List<Permission> children) {
		this.children = children;
	}
	@ManyToMany(mappedBy = "permissions")
	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	private Permission parent;
	private List<Permission> children;
	private List<Role>roles;
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
}
